home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / texted1a / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-12  |  27.4 KB  |  759 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  4. Begin VB.MDIForm frmMain 
  5.    Appearance      =   0  'Flat
  6.    BackColor       =   &H00404040&
  7.    Caption         =   "Text Editor"
  8.    ClientHeight    =   6285
  9.    ClientLeft      =   165
  10.    ClientTop       =   450
  11.    ClientWidth     =   7395
  12.    Icon            =   "frmMain.frx":0000
  13.    LinkTopic       =   "MDIForm1"
  14.    StartUpPosition =   2  'CenterScreen
  15.    WindowState     =   2  'Maximized
  16.    Begin MSComctlLib.Toolbar tbFind 
  17.       Align           =   1  'Align Top
  18.       Height          =   630
  19.       Left            =   0
  20.       TabIndex        =   4
  21.       Top             =   915
  22.       Visible         =   0   'False
  23.       Width           =   7395
  24.       _ExtentX        =   13044
  25.       _ExtentY        =   1111
  26.       ButtonWidth     =   609
  27.       ButtonHeight    =   953
  28.       AllowCustomize  =   0   'False
  29.       Appearance      =   1
  30.       _Version        =   393216
  31.       Begin VB.CommandButton cmdCancel 
  32.          Caption         =   "&Cancel"
  33.          Height          =   255
  34.          Left            =   5880
  35.          TabIndex        =   7
  36.          Top             =   120
  37.          Width           =   855
  38.       End
  39.       Begin VB.CommandButton cmdFindNext 
  40.          Caption         =   "Find Next"
  41.          Height          =   255
  42.          Left            =   4800
  43.          TabIndex        =   6
  44.          Top             =   120
  45.          Width           =   975
  46.       End
  47.       Begin VB.TextBox Text1 
  48.          Height          =   285
  49.          Left            =   0
  50.          TabIndex        =   0
  51.          Text            =   "Search For What?"
  52.          Top             =   120
  53.          Width           =   3735
  54.       End
  55.       Begin VB.CommandButton cmdFind 
  56.          Caption         =   "&Find"
  57.          Default         =   -1  'True
  58.          Enabled         =   0   'False
  59.          Height          =   255
  60.          Left            =   3960
  61.          TabIndex        =   5
  62.          Top             =   120
  63.          Width           =   735
  64.       End
  65.    End
  66.    Begin VB.PictureBox pctBar1 
  67.       Align           =   1  'Align Top
  68.       BackColor       =   &H00FFFFFF&
  69.       Height          =   495
  70.       Left            =   0
  71.       Picture         =   "frmMain.frx":27A2
  72.       ScaleHeight     =   435
  73.       ScaleWidth      =   7335
  74.       TabIndex        =   3
  75.       Top             =   420
  76.       Width           =   7395
  77.       Begin VB.Label lblDocName 
  78.          BackStyle       =   0  'Transparent
  79.          Caption         =   "Document Title"
  80.          BeginProperty Font 
  81.             Name            =   "Times New Roman"
  82.             Size            =   26.25
  83.             Charset         =   0
  84.             Weight          =   700
  85.             Underline       =   0   'False
  86.             Italic          =   -1  'True
  87.             Strikethrough   =   0   'False
  88.          EndProperty
  89.          ForeColor       =   &H000000FF&
  90.          Height          =   495
  91.          Left            =   0
  92.          TabIndex        =   8
  93.          Top             =   -120
  94.          Width           =   11415
  95.       End
  96.    End
  97.    Begin MSComctlLib.StatusBar StatusBar1 
  98.       Align           =   2  'Align Bottom
  99.       Height          =   255
  100.       Left            =   0
  101.       TabIndex        =   2
  102.       Top             =   6030
  103.       Width           =   7395
  104.       _ExtentX        =   13044
  105.       _ExtentY        =   450
  106.       _Version        =   393216
  107.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  108.          NumPanels       =   4
  109.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  110.             Style           =   1
  111.             Enabled         =   0   'False
  112.             Object.Width           =   1129
  113.             MinWidth        =   1129
  114.             Text            =   "CAPS"
  115.             TextSave        =   "CAPS"
  116.          EndProperty
  117.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  118.             Style           =   2
  119.             Enabled         =   0   'False
  120.             Object.Width           =   1129
  121.             MinWidth        =   1129
  122.             TextSave        =   "NUM"
  123.          EndProperty
  124.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  125.             Object.Width           =   12771
  126.             MinWidth        =   12771
  127.             Text            =   "Document"
  128.             TextSave        =   "Document"
  129.          EndProperty
  130.          BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  131.             Style           =   5
  132.             Object.Width           =   1482
  133.             MinWidth        =   1482
  134.             Text            =   "Doc"
  135.             TextSave        =   "5:20 PM"
  136.          EndProperty
  137.       EndProperty
  138.    End
  139.    Begin MSComDlg.CommonDialog dlgCommonDialog 
  140.       Left            =   1740
  141.       Top             =   1320
  142.       _ExtentX        =   847
  143.       _ExtentY        =   847
  144.       _Version        =   393216
  145.    End
  146.    Begin MSComctlLib.ImageList imlToolbarIcons 
  147.       Left            =   3000
  148.       Top             =   1560
  149.       _ExtentX        =   1005
  150.       _ExtentY        =   1005
  151.       BackColor       =   -2147483643
  152.       ImageWidth      =   16
  153.       ImageHeight     =   16
  154.       MaskColor       =   12632256
  155.       _Version        =   393216
  156.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  157.          NumListImages   =   13
  158.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  159.             Picture         =   "frmMain.frx":7722
  160.             Key             =   "New"
  161.          EndProperty
  162.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  163.             Picture         =   "frmMain.frx":7834
  164.             Key             =   "Open"
  165.          EndProperty
  166.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  167.             Picture         =   "frmMain.frx":7946
  168.             Key             =   "Save"
  169.          EndProperty
  170.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  171.             Picture         =   "frmMain.frx":7A58
  172.             Key             =   "Print"
  173.          EndProperty
  174.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  175.             Picture         =   "frmMain.frx":7B6A
  176.             Key             =   "Cut"
  177.          EndProperty
  178.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  179.             Picture         =   "frmMain.frx":7C7C
  180.             Key             =   "Copy"
  181.          EndProperty
  182.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  183.             Picture         =   "frmMain.frx":7D8E
  184.             Key             =   "Paste"
  185.          EndProperty
  186.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  187.             Picture         =   "frmMain.frx":7EA0
  188.             Key             =   "Bold"
  189.          EndProperty
  190.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  191.             Picture         =   "frmMain.frx":7FB2
  192.             Key             =   "Italic"
  193.          EndProperty
  194.          BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  195.             Picture         =   "frmMain.frx":80C4
  196.             Key             =   "Underline"
  197.          EndProperty
  198.          BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  199.             Picture         =   "frmMain.frx":81D6
  200.             Key             =   "Align Left"
  201.          EndProperty
  202.          BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  203.             Picture         =   "frmMain.frx":82E8
  204.             Key             =   "Center"
  205.          EndProperty
  206.          BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  207.             Picture         =   "frmMain.frx":83FA
  208.             Key             =   "Align Right"
  209.          EndProperty
  210.       EndProperty
  211.    End
  212.    Begin MSComctlLib.Toolbar tbToolBar 
  213.       Align           =   1  'Align Top
  214.       Height          =   420
  215.       Left            =   0
  216.       TabIndex        =   1
  217.       Top             =   0
  218.       Width           =   7395
  219.       _ExtentX        =   13044
  220.       _ExtentY        =   741
  221.       ButtonWidth     =   609
  222.       ButtonHeight    =   582
  223.       AllowCustomize  =   0   'False
  224.       Appearance      =   1
  225.       ImageList       =   "imlToolbarIcons"
  226.       _Version        =   393216
  227.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  228.          NumButtons      =   11
  229.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  230.             Key             =   "New"
  231.             Object.ToolTipText     =   "New"
  232.             ImageKey        =   "New"
  233.          EndProperty
  234.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  235.             Key             =   "Open"
  236.             Object.ToolTipText     =   "Open"
  237.             ImageKey        =   "Open"
  238.          EndProperty
  239.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  240.             Key             =   "Save"
  241.             Object.ToolTipText     =   "Save"
  242.             ImageKey        =   "Save"
  243.          EndProperty
  244.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  245.             Style           =   3
  246.          EndProperty
  247.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  248.             Key             =   "Cut"
  249.             Object.ToolTipText     =   "Cut"
  250.             ImageKey        =   "Cut"
  251.          EndProperty
  252.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  253.             Key             =   "Copy"
  254.             Object.ToolTipText     =   "Copy"
  255.             ImageKey        =   "Copy"
  256.          EndProperty
  257.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  258.             Key             =   "Paste"
  259.             Object.ToolTipText     =   "Paste"
  260.             ImageKey        =   "Paste"
  261.          EndProperty
  262.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  263.             Style           =   3
  264.          EndProperty
  265.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  266.             Key             =   "Bold"
  267.             Object.ToolTipText     =   "Bold"
  268.             ImageKey        =   "Bold"
  269.          EndProperty
  270.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  271.             Key             =   "Italic"
  272.             Object.ToolTipText     =   "Italic"
  273.             ImageKey        =   "Italic"
  274.          EndProperty
  275.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  276.             Key             =   "Underline"
  277.             Object.ToolTipText     =   "Underline"
  278.             ImageKey        =   "Underline"
  279.          EndProperty
  280.       EndProperty
  281.    End
  282.    Begin VB.Menu mnuFile 
  283.       Caption         =   "&File"
  284.       Begin VB.Menu mnuFileNew 
  285.          Caption         =   "&New"
  286.       End
  287.       Begin VB.Menu mnuFileOpen 
  288.          Caption         =   "&Open"
  289.          Shortcut        =   ^O
  290.       End
  291.       Begin VB.Menu mnuFileSeperator1 
  292.          Caption         =   "-"
  293.       End
  294.       Begin VB.Menu mnuFileSave 
  295.          Caption         =   "&Save"
  296.          Enabled         =   0   'False
  297.       End
  298.       Begin VB.Menu mnuFileSaveAs 
  299.          Caption         =   "Save &As"
  300.       End
  301.       Begin VB.Menu mnuFileSeperator2 
  302.          Caption         =   "-"
  303.       End
  304.       Begin VB.Menu mnuFilePageSetup 
  305.          Caption         =   "Page Setup"
  306.       End
  307.       Begin VB.Menu mnuFilePrint 
  308.          Caption         =   "Print"
  309.       End
  310.       Begin VB.Menu mnuFileSeperator3 
  311.          Caption         =   "-"
  312.       End
  313.       Begin VB.Menu mnuFileExit 
  314.          Caption         =   "&Exit"
  315.       End
  316.       Begin VB.Menu mnuRecentFile 
  317.          Caption         =   "-"
  318.          Index           =   0
  319.          Visible         =   0   'False
  320.       End
  321.       Begin VB.Menu mnuRecentFile 
  322.          Caption         =   "RecentFile1"
  323.          Index           =   1
  324.          Visible         =   0   'False
  325.       End
  326.       Begin VB.Menu mnuRecentFile 
  327.          Caption         =   "RecentFile2"
  328.          Index           =   2
  329.          Visible         =   0   'False
  330.       End
  331.       Begin VB.Menu mnuRecentFile 
  332.          Caption         =   "RecentFile3"
  333.          Index           =   3
  334.          Visible         =   0   'False
  335.       End
  336.       Begin VB.Menu mnuRecentFile 
  337.          Caption         =   "RecentFile4"
  338.          Index           =   4
  339.          Visible         =   0   'False
  340.       End
  341.       Begin VB.Menu mnuRecentFile 
  342.          Caption         =   "RecentFile5"
  343.          Index           =   5
  344.          Visible         =   0   'False
  345.       End
  346.    End
  347.    Begin VB.Menu mnuEdit 
  348.       Caption         =   "&Edit"
  349.       Begin VB.Menu mnuEditCut 
  350.          Caption         =   "C&ut"
  351.       End
  352.       Begin VB.Menu mnuEditCopy 
  353.          Caption         =   "&Copy"
  354.       End
  355.       Begin VB.Menu mnuEditPaste 
  356.          Caption         =   "&Paste"
  357.       End
  358.       Begin VB.Menu mnuFileSeperator5 
  359.          Caption         =   "-"
  360.       End
  361.       Begin VB.Menu mnuEditFind 
  362.          Caption         =   "&Find"
  363.       End
  364.       Begin VB.Menu mnuEditFindNext 
  365.          Caption         =   "Find &Next"
  366.          Shortcut        =   {F3}
  367.       End
  368.       Begin VB.Menu mnuFileSeperator6 
  369.          Caption         =   "-"
  370.       End
  371.       Begin VB.Menu mnuEditTime 
  372.          Caption         =   "&Time/Date"
  373.       End
  374.       Begin VB.Menu mnuEditSelectAll 
  375.          Caption         =   "&Select All"
  376.       End
  377.    End
  378.    Begin VB.Menu mnuFonts 
  379.       Caption         =   "F&onts"
  380.       Begin VB.Menu mnuFontsFont 
  381.          Caption         =   "&Font"
  382.          Index           =   0
  383.       End
  384.       Begin VB.Menu mnuFontsColor 
  385.          Caption         =   "&Color"
  386.       End
  387.    End
  388.    Begin VB.Menu mnuView 
  389.       Caption         =   "&View"
  390.       Begin VB.Menu mnuViewToolbar 
  391.          Caption         =   "&Toolbar"
  392.          Checked         =   -1  'True
  393.       End
  394.    End
  395.    Begin VB.Menu mnuWindow 
  396.       Caption         =   "&Window"
  397.       WindowList      =   -1  'True
  398.       Begin VB.Menu mnuWindowArrangeIcons 
  399.          Caption         =   "Arrange Icons"
  400.       End
  401.       Begin VB.Menu mnuWindowTileVertical 
  402.          Caption         =   "Tile Vertical"
  403.       End
  404.       Begin VB.Menu mnuWindowCascade 
  405.          Caption         =   "Cascade"
  406.       End
  407.       Begin VB.Menu mnuWindowTileHorizontal 
  408.          Caption         =   "Tile Horizontal"
  409.       End
  410.    End
  411.    Begin VB.Menu mnuHelp 
  412.       Caption         =   "&Help"
  413.       Begin VB.Menu mnuHelpAbout 
  414.          Caption         =   "&About"
  415.       End
  416.    End
  417. Attribute VB_Name = "frmMain"
  418. Attribute VB_GlobalNameSpace = False
  419. Attribute VB_Creatable = False
  420. Attribute VB_PredeclaredId = True
  421. Attribute VB_Exposed = False
  422. 'Some Notes on some of the functions I used:
  423. 'ActiveForm:
  424. '  The ActiveForm function that I used is used mostly when you are creating a
  425. 'MDI Application. I used it on alot of things because I've either forgotten
  426. 'Any other way to do it or never knew how to do it any other way.
  427. 'Other Notes:
  428. 'Im sorry about the mess of the application up to this one. I was using different methods
  429. 'Of doing things.. Some harder, some easier/faster.
  430. Dim DocChanged2 As Boolean
  431. Option Explicit
  432. 'This is for the find function
  433. Private Sub cmdCancel_Click()
  434.     tbFind.Visible = False
  435.     mnuEditFind.Checked = False
  436. End Sub
  437. 'This is for the find function
  438. Private Sub cmdFind_Click()
  439. Dim textfound As Integer
  440.     ' Finds the text in the search box and highlights it,
  441.     ' then sets the focus on the richtextbox so the selected
  442.     ' text is editable.
  443. ActiveForm.rtfBox1.Find (Text1.Text)
  444.     'Sets the window/blinking thing to the rtfBox
  445. ActiveForm.rtfBox1.SetFocus
  446.     ' The ActiveForm.rtfBox1.Find method returns an integer
  447.     ' value of -1 if the searched for text is not found.
  448.     ' If this is true then it displays a message box.
  449.     textfound = ActiveForm.rtfBox1.Find(Text1.Text)
  450.     If textfound = -1 Then
  451.     MsgBox "Search finished. No text found!", vbInformation, "No Text Found"
  452. End If
  453. End Sub
  454. 'This routes the FindNext to the menu, that way I dont have to write more lines
  455. 'Of code to make it do the exact same thing.
  456. Private Sub cmdFindNext_Click()
  457.     mnuEditFindNext_Click
  458. End Sub
  459. Private Sub MDIForm_Load()
  460. 'This automatically opens a new document when the project loads.
  461.    LoadNewDoc
  462.     StatusBar1.Panels(3).Text = ActiveForm.Caption
  463.     ChDir App.Path
  464.     lblDocName.Caption = ActiveForm.Caption
  465. End Sub
  466. Private Sub mnuEditCopy_Click()
  467. 'When someone clicks the menu Edit and Copy it will copy the selected text into the clipboard.
  468.     On Error Resume Next
  469.     Clipboard.SetText ActiveForm.rtfBox1.SelRTF
  470. End Sub
  471. Private Sub mnuEditCut_Click()
  472. 'When someone click the menu Edit and Cut it will Remove the text from the document and put it on the clipboard.
  473.     On Error Resume Next
  474.     Clipboard.SetText ActiveForm.rtfBox1.SelRTF
  475.     ActiveForm.rtfBox1.SelText = vbNullString
  476. End Sub
  477. Private Sub mnuEditFind_Click()
  478. 'When someone clicks the menu Edit Find this will un hide the ToolBar for the find proc
  479. If tbFind.Visible = False Then
  480.     tbFind.Visible = True
  481.     mnuEditFind.Checked = True
  482.         If tbToolBar.Visible = False Then
  483.         
  484.         End If
  485.     ' This routine hides the Find Toolbar.
  486.     ' And resizes the richtextbox dependin on whether or not the
  487.     ' standard toolbar is shown.
  488.     tbFind.Visible = False
  489.     mnuEditFind.Checked = False
  490.         If tbToolBar.Visible = False Then
  491.         
  492.         End If
  493. End If
  494. End Sub
  495. 'Finds the next word the person has entered in the box.
  496. Private Sub mnuEditFindNext_Click()
  497.     ' Set the focus so the selected text can be directly edited.
  498. ActiveForm.rtfBox1.SetFocus
  499.     ' Finds the next instance of the word, starting from
  500.     ' the selected text.
  501. ActiveForm.rtfBox1.Find (Text1.Text), ActiveForm.rtfBox1.SelStart + 1
  502. End Sub
  503. Private Sub mnuEditPaste_Click()
  504. 'When someone clicks the menu Edit and Paste it will paste what ever text is on the clipboard into the current open document.
  505.        On Error Resume Next
  506.     ActiveForm.rtfBox1.SelRTF = Clipboard.GetText
  507. End Sub
  508. Private Sub mnuEditSelectAll_Click()
  509. 'When someone clicks the menu Edit and Select All it will Select All text in the document.
  510.     On Error Resume Next
  511.     ' Use SelStart & SelLength to select the text.
  512.     ActiveForm.rtfBox1.SelStart = 0
  513.     ActiveForm.rtfBox1.SelLength = Len(ActiveForm.rtfBox1.Text)
  514. End Sub
  515. Private Sub mnuEditTime_Click()
  516.     On Error Resume Next
  517.     'Display current time & Date
  518.     ActiveForm.rtfBox1.SelRTF = Now
  519. End Sub
  520. Private Sub mnuFileExit_Click()
  521.     End
  522. End Sub
  523. 'Allows the person to save the file they made in either .TXT or .WRI or any other format they want.
  524. Private Sub mnuFileSave_Click()
  525. '        SaveDoc
  526.   Dim sFile As String
  527.   Dim sTitle As String
  528.   If Left$(ActiveForm.Caption, 8) = "Untitled" Then
  529.       With dlgCommonDialog
  530.           .DialogTitle = "Save File"
  531.           .CancelError = False
  532.           .FileName = ActiveForm.Caption
  533.           .Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt
  534.           .Filter = "Ritch Text Files (*.wri)|*.wri|Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
  535.           .ShowSave
  536.           If Len(.FileName) = 0 Then
  537.               Exit Sub
  538.           End If
  539.           sFile = .FileName
  540.           sTitle = .FileTitle
  541.           If UCase(Right(ActiveForm.rtfBox1.FileName, 3)) = "WRI" Then
  542.               ActiveForm.rtfBox1.SaveFile sFile, rtfRTF
  543.           Else
  544.               ActiveForm.rtfBox1.SaveFile sFile, rtfText
  545.           End If
  546.           DocChanged2 = False
  547.       End With
  548.       ActiveForm.Caption = sTitle
  549.      fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle
  550.      fMainForm.lblDocName.Caption = ActiveForm.Caption
  551.     ActiveForm.rtfBox1.SaveFile sFile
  552.   Else
  553.     ActiveForm.rtfBox1.SaveFile sFile, rtfText
  554.     End If
  555. End Sub
  556. 'This is so when they click File and SaveAs it will open a SaveAs dialog box so the text document can be saved into another file.
  557. Private Sub mnuFileSaveAs_Click()
  558.     Dim sFile As String
  559.     Dim sTitle As String
  560.     Dim DocChanged
  561.     DocChanged = False
  562.     If ActiveForm Is Nothing Then Exit Sub
  563.     With dlgCommonDialog
  564.         .DialogTitle = "Save As"
  565.         .CancelError = False
  566.         .Filter = "Ritch Text Files (*.wri)|*.wri|Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
  567.         .Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt
  568.         .ShowSave
  569.         If Len(.FileName) = 0 Then
  570.             Exit Sub
  571.         End If
  572.         sFile = .FileName
  573.         sTitle = .FileTitle
  574.         If UCase(Right(ActiveForm.rtfBox1.FileName, 3)) = "WRI" Then
  575.             ActiveForm.rtfBox1.SaveFile sFile, rtfRTF
  576.         Else
  577.             ActiveForm.rtfBox1.SaveFile sFile, rtfText
  578.         End If
  579.         DocChanged = False
  580.     End With
  581.     ActiveForm.Caption = sTitle
  582.     fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle
  583.     fMainForm.lblDocName.Caption = ActiveForm.Caption
  584. End Sub
  585. Private Sub mnuFontsColor_Click()
  586.     ' Shows the color dialog box and sets the current color.
  587. dlgCommonDialog.Flags = cdlCCFullOpen
  588. dlgCommonDialog.ShowColor
  589. ActiveForm.rtfBox1.SelColor = dlgCommonDialog.Color
  590. End Sub
  591. Private Sub mnuFontsFont_Click(Index As Integer)
  592.     ' Shows the Font dialogue box and sets the current font.
  593. dlgCommonDialog.Flags = cdlCFBoth Or cdlCFEffects
  594. dlgCommonDialog.ShowFont
  595. With ActiveForm.rtfBox1
  596.     .SelFontName = dlgCommonDialog.FontName
  597.     .SelFontSize = dlgCommonDialog.FontSize
  598.     .SelBold = dlgCommonDialog.FontBold
  599.     .SelItalic = dlgCommonDialog.FontItalic
  600.     .SelStrikeThru = dlgCommonDialog.FontStrikethru
  601.     .SelUnderline = dlgCommonDialog.FontUnderline
  602.     .SelColor = dlgCommonDialog.Color
  603. End With
  604. End Sub
  605. 'This is so the user can hide and view the toolbar.. Im thinking of making it so they can customize the toolbar.
  606. Private Sub mnuViewToolbar_Click()
  607.     mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
  608.     tbToolBar.Visible = mnuViewToolbar.Checked
  609. End Sub
  610. 'This is for the toolbar so that when someone clicks on the buttons it will do the action.
  611. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)
  612.     Select Case Button.Key
  613.         Case "New"
  614.     On Error Resume Next
  615.             LoadNewDoc
  616.         Case "Open"
  617.     On Error Resume Next
  618.             mnuFileOpen_Click
  619.         Case "Save"
  620.     On Error Resume Next
  621.             mnuFileSave_Click
  622.         Case "Cut"
  623.     On Error Resume Next
  624.             mnuEditCut_Click
  625.         Case "Copy"
  626.     On Error Resume Next
  627.             mnuEditCopy_Click
  628.         Case "Paste"
  629.     On Error Resume Next
  630.             mnuEditPaste_Click
  631.         Case "Bold"
  632.     On Error Resume Next
  633.             ActiveForm.rtfBox1.SelBold = Not ActiveForm.rtfBox1.SelBold
  634.             Button.Value = IIf(ActiveForm.rtfBox1.SelBold, tbrPressed, tbrUnpressed)
  635.         Case "Italic"
  636.     On Error Resume Next
  637.             ActiveForm.rtfBox1.SelItalic = Not ActiveForm.rtfBox1.SelItalic
  638.             Button.Value = IIf(ActiveForm.rtfBox1.SelItalic, tbrPressed, tbrUnpressed)
  639.         Case "Underline"
  640.     On Error Resume Next
  641.             ActiveForm.rtfBox1.SelUnderline = Not ActiveForm.rtfBox1.SelUnderline
  642.             Button.Value = IIf(ActiveForm.rtfBox1.SelUnderline, tbrPressed, tbrUnpressed)
  643.     End Select
  644. End Sub
  645. 'Private Sub LoadNewDoc()
  646. '    Static lDocumentCount As Long
  647. '    Dim frmDoc As frmText1
  648. '    lDocumentCount = lDocumentCount + 1
  649. '    Set frmDoc = New frmText1
  650. '    frmDoc.Caption = "TextBox " & lDocumentCount
  651. '    frmDoc.Show
  652. 'End Sub
  653. Private Sub mnuFileOpen_Click()
  654.     Dim sFile As String
  655.     Dim sTitle As String
  656. '    Dim strOpenFileName As String
  657.     If ActiveForm Is Nothing Then LoadNewDoc
  658.     With dlgCommonDialog
  659.         .DialogTitle = "Open Text Document"
  660.         .FileName = ""
  661.         .CancelError = False
  662.         .Filter = "Text Files (*.txt)|*.txt|Ritch Text Files (*.wri)|*.wri|All Files (*.*)|*.*"
  663.         .Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
  664.         .ShowOpen
  665.         ' If the file is larger than 65K, it can't
  666.         ' be opened, so cancel the operation.
  667. '        On Error GoTo DiskErrorHandler
  668.         If FileLen(.FileName) > 65000 Then
  669.             MsgBox "The file is too large to open."
  670.             Exit Sub
  671.         End If
  672.         If Len(.FileName) = 0 Then
  673.             Exit Sub
  674.         End If
  675. '        strOpenFileName = fMainForm.dlgCommonDialog.Filename
  676.         sFile = .FileName
  677.         sTitle = .FileTitle
  678.     End With
  679.     LoadNewDoc
  680.     ActiveForm.rtfBox1.LoadFile sFile
  681.     ActiveForm.Caption = "Open Document - " & sTitle
  682.     fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle
  683.     fMainForm.lblDocName.Caption = ActiveForm.Caption
  684. 'DiskErrorHandler:
  685. 'Select Case Err.Number
  686. '    Case ErrInvalidFileName, ErrBadFileName
  687. '        MsgBox "There was an Error!", vbOKOnly, "Cannot find File"
  688. '    Case 53
  689. '   M$ = "The file you specified was not found. Please check your spelling and try again.. Error 53!"
  690. '    Case 55
  691. '   M$ = "The file you specified is already open it. Please close it and try again. Error 55!"
  692. '    Case Else
  693. '        Dim intErrNum As Integer
  694. '        intErrNum = Err.Number
  695. '        Err.Clear       'Clear the Err oject.
  696. '        Err.Raise Number:=intErrNum 'Regenerate the error.
  697. '        MsgBox "There was an Error!", vbOKOnly, "Cannot find File"
  698. '  End Select
  699. '  M$ = M$ + vbCrLf + vbCrLf + "For a Error Number list check the help file. Error Number: " & Err.Number & " has occured "
  700. '  M$ = M$ + ""
  701. '  WhatToDo% = MsgBox(M$, vbCritical, "Error Number " & Err.Number & " has occured! ")
  702. '  If WhatToDo% = vbYes Then
  703. End Sub
  704. Private Sub mnuFileNew_Click()
  705. 'When someone clicks File and New it will create a new document.
  706.     LoadNewDoc
  707. End Sub
  708. 'Allows the user to print a document hopefully
  709. Private Sub mnuFilePrint_Click()
  710.     On Error Resume Next
  711.     If ActiveForm Is Nothing Then Exit Sub
  712.     With dlgCommonDialog
  713.         .DialogTitle = "Print - Print Now"
  714.         .CancelError = True
  715.         .Flags = cdlPDReturnDC + cdlPDNoPageNums
  716.         If ActiveForm.rtfBox1.SelLength = 0 Then
  717.             .Flags = .Flags + cdlPDAllPages
  718.         Else
  719.             .Flags = .Flags + cdlPDSelection
  720.         End If
  721.         .ShowPrinter
  722.         If Err <> MSComDlg.cdlCancel Then
  723.             ActiveForm.rtfBox1.SelPrint .hDC
  724.         End If
  725.     End With
  726. End Sub
  727. Private Sub mnuFilePageSetup_Click()
  728.     On Error Resume Next
  729.     With dlgCommonDialog
  730.         .DialogTitle = "Print - Page Setup"
  731.         .CancelError = True
  732.         .ShowPrinter
  733.     End With
  734. End Sub
  735. 'Allows user to Arrange the Windows
  736. Private Sub mnuWindowArrangeIcons_Click()
  737.     Me.Arrange vbArrangeIcons
  738. End Sub
  739. 'Allows user to Arrange the Windows
  740. Private Sub mnuWindowTileVertical_Click()
  741.     Me.Arrange vbTileVertical
  742. End Sub
  743. 'Allows user to Arrange the Windows
  744. Private Sub mnuWindowTileHorizontal_Click()
  745.     Me.Arrange vbTileHorizontal
  746. End Sub
  747. 'Allows user to Arrange the Windows
  748. Private Sub mnuWindowCascade_Click()
  749.     Me.Arrange vbCascade
  750. End Sub
  751. 'This is as a backup just incase one of the forms are still open when the user closes the main window, this will close the entire program to save memory.
  752. Private Sub MDIForm_Unload(cancel As Integer)
  753.   End
  754. End Sub
  755. Private Sub Text1_Change()
  756.     ' Enables the find button when the search text is entered.
  757. cmdFind.Enabled = True
  758. End Sub
  759.